package com.starview.star.compiler.operator;

import com.starview.star.compiler.standard.StandardNames;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class RightAssocOperator extends InfixOperator
{
  public RightAssocOperator(String operator, int priority)
  {
    super(operator, priority, OperatorForm.right);
  }

  public RightAssocOperator(String operator, int priority, int minPriority)
  {
    super(operator, minPriority, priority, OperatorForm.right);
  }

  @Override
  public int rightPriority()
  {
    return getPriority();
  }

  @Override
  public String toLatex()
  {
    return "\\tt " + StandardNames.latexString(getOperator()) + "&" + getPriority() + "&right";
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    disp.append(StandardNames.META_HASH);
    disp.append(StandardNames.RIGHT);
    disp.append("((");
    disp.append(getOperator());
    disp.append("),");
    disp.append(getPriority());
    if (getMinPriority() > 0) {
      disp.append(",");
      disp.append(getMinPriority());
    }
    disp.append(")");
  }
}
